<template>
	<view class="column-css" v-show="isResult">
		<view class="column-css" style="margin-top: 200rpx; align-items: center;text-align: center;">
			<image style="width: 165rpx;height: 165rpx;border-radius: 50%;overflow:hidden;" src="../../static/icon_ecco.png" v-if="type === 'success'"></image>
			<image style="width: 165rpx;height: 165rpx;border-radius: 50%;overflow:hidden;" src="../../static/icon_home_err.png" v-if="type === 'fail'"></image>
			<view>
				<view style="font-size: 36rpx;margin-top: 30rpx;">{{ resultTitle }}</view>
			</view>
		</view>
		<view style="margin-top: 20rpx;padding:80rpx 100rpx;text-align: center;">{{ resultDes }}</view>
		<view class="resutl-btn-box">
			<button class="reset-button action-btn" @click="goLogin(newMobile)" v-if="type == 'success'">重新登录</button>
			<button class="reset-button action-btn" @click="goAuth()" v-if="type == 'fail'">重新认证</button>
			<button class="reset-button action-btn" @click="backAuth()" v-if="type == 'fail'">退出认证</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isResult: false,
			type: '',
			resultTitle: '',
			resultDes: '',
			runNum: 0,
			newMobile: ''
		};
	},
	onLoad(options) {
		this.type = options.type
		this.isResult = true
		if (this.type == 'success') {
			this.newMobile = options.tel
			this.resultTitle = '账号找回成功';
			this.resultDes = '请返回登录页，并使用手机号'+ this.newMobile +'重新登录账号'
		} else if (this.type == 'fail') {
			this.resultTitle = '账号验证失败';
			this.resultDes = '账号验证失败，请联系平台管理员找回账号并修改登录手机号'
		}
	},
	methods: {
		runGet() {
			setTimeout(() => {
				this.runNum++
				uni.setStorageSync('back_result_run', this.runNum)
				if (this.runNum < 3 && !this.isResult) {
					this.getResult()
					this.runGet()
				} else {
					uni.removeStorageSync('back_result_run')
				}
			},2000)
		},
		getResult() {
			uni.showLoading({
				title: '加载中...'
			})
			setTimeout(()=> {
				uni.hideLoading()
				this.isResult = true
				this.type = 'success';
				this.resultTitle = '账号找回成功';
				this.resultDes = '请返回登录页，并使用手机号138000000重新登录账号'
				this.type = 'fail';
				this.resultTitle = '账号验证失败';
				this.resultDes = '账号验证失败，请联系平台管理员找回账号并修改登录手机号'
			},3000)
			
			// this.wxRequest({
			// 	url: `${this.API}`,
			// 	method: 'POST',
			// 	data: {
			// 		trueName: this.trueName,
			// 		idNo: this.idNo,
			// 		accountNo: this.accountNo,
			// 		businessNo: this.businessNo
			// 	},
			// 	title: '加载中...',
			// 	success: res => {
			// 		if (res.data.code == 0) {
			// 			uni.hideLoading()
			// 			this.isResult = true
			// 			this.type = 'success';
			// 			this.resultTitle = '账号找回成功';
			// 			this.resultDes = '请返回登录页，并使用手机号138000000重新登录账号'
			// 		} else {
			// 			if (this.runNum == 2) {
			// 				uni.hideLoading()
			// 				this.isResult = true
			// 				this.type = 'fail';
			// 				this.resultTitle = '账号验证失败';
			// 				this.resultDes = '账号验证失败，请联系平台管理员找回账号并修改登录手机号'
			// 				this.runNum = 0
			// 			}
			// 		}
			// 	}
			// });
		},
		backAuth() {
			uni.switchTab({
				url: '/pages/index/taskhome'
			})
		},
		goLogin(mobile) {
			uni.navigateTo({
				url: '/pages/personal/login',
				success(res) {
					mobile && res.eventChannel.emit('login', { phone: mobile })
				}
			})
		},
		goAuth() {
			uni.navigateBack({
				delta: 1
			})
		},
	},
};
</script>

<style lang="scss">
.reset-button {
	  padding: 0;
	  margin: 0;
	  font-size: inherit;
	  background-color: transparent;
	  color: inherit;
	  position: relative;
	  border: 0rpx;
	  /* #ifndef APP-NVUE */
	  display: flex;
	  /* #endif */
	  align-items: center;
	  justify-content: center;
	  box-sizing: border-box;
	  text-align: center;
	  text-decoration: none;
	  white-space: nowrap;
	  vertical-align: baseline;
	  transform: translate(0, 0);
	}
	.reset-button.button-hover {
	  transform: translate(1px, 1px);
	  background: none;
	}
	
	.reset-button::after {
	  border: none;
	}
	.result-content {
		padding: 0 30rpx;
		font-size: 26rpx;
		color: #333;
	}
page {
	background: #ffffff;
}
.row-css {
	display: flex;
	flex-direction: row;
}

.column-css {
	display: flex;
	flex-direction: column;
}

.view-button {
	display: flex;
	flex: 1;
	background: #2b7cff;
	border-radius: 15rpx;
	padding: 20rpx;
	margin: 0 30rpx;
	margin-top: 50rpx;
	justify-content: center;
	color: #ffffff;
}
.resutl-btn-box button {
	margin-bottom: 20px;
}
.action-btn {
	background: #2b7cff;
	color: #fff;
	margin: 0 30rpx;
	&.button-hover {
	  background: rgba(43, 124, 255, .9);
	}
}
</style>
